package com.gitee.wsl.mathematics.base

import com.gitee.wsl.mathematics.number.NumberCalcContainer


/** Calculates (x^2 + y^2) without overflow/underflow. */
internal fun sqrHypot2(x: Float, y: Float) = x * x + y * y

/** Calculates (x^2 + y^2 + z^2) without overflow/underflow. */
internal fun sqrHypot3(x: Float, y: Float, z: Float) = x * x + y * y + z * z

/** Calculates (x^2 + y^2 + z^2 + w^2) without overflow/underflow. */
internal fun sqrHypot4(x: Float, y: Float, z: Float, w: Float) = x * x + y * y + z * z + w * w

/** Calculate sum of all given params. */
internal fun sumOf2(x: Float, y: Float) = x + y

/** Calculate sum of all given params. */
internal fun sumOf3(x: Float, y: Float, z: Float) = x + y + z

/** Calculate sum of all given params. */
internal fun sumOf4(x: Float, y: Float, z: Float, w: Float) = x + y + z + w

/** A function accepting a single parameter of type T, returns an object of type R. */
internal typealias Mapping<T, R> = (T) -> R
/** A function accepting two parameters of type T, returns an object of type R. */
internal typealias Mapping2<T, R> = (T, T) -> R
/** A function accepting three parameters of type T, returns an object of type R. */
internal typealias Mapping3<T, R> = (T, T, T) -> R
/** A function accepting four parameters of type T, returns an object of type R. */
internal typealias Mapping4<T, R> = (T, T, T, T) -> R
/** A function accepting nine parameters of type T, returns an object of type R. */
internal typealias Mapping9<T, R> = (T, T, T, T, T, T, T, T, T) -> R
/** A function accepting sixteen parameters of type T, returns an object of type R. */
internal typealias Mapping16<T, R> = (T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) -> R

/** A function accepting a single parameter of type T, returns an object of type R. */
internal typealias NumberMapping<T, R> = NumberCalcContainer<T>.(T) -> R
/** A function accepting two parameters of type T, returns an object of type R. */
internal typealias NumberMapping2<T, R> = NumberCalcContainer<T>.(T, T) -> R
/** A function accepting three parameters of type T, returns an object of type R. */
internal typealias NumberMapping3<T, R> = NumberCalcContainer<T>.(T, T, T) -> R
/** A function accepting four parameters of type T, returns an object of type R. */
internal typealias NumberMapping4<T, R> = NumberCalcContainer<T>.(T, T, T, T) -> R
/** A function accepting nine parameters of type T, returns an object of type R. */
internal typealias NumberMapping9<T, R> = NumberCalcContainer<T>.(T, T, T, T, T, T, T, T, T) -> R
/** A function accepting sixteen parameters of type T, returns an object of type R. */
internal typealias NumberMapping16<T, R> = NumberCalcContainer<T>.(T, T, T, T, T, T, T, T, T, T, T, T, T, T, T, T) -> R
